package cn.findviewbydream.evil.main.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/********************************************
 * 工程名：MealOrder
 * 包名：cn.findviewbydream.evil.main.interceptor
 * 时间：17-2-21
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：
 ********************************************/
public class SettingInterceptor implements HandlerInterceptor
{
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response
            , Object o) throws Exception
    {
        String x_pjax = request.getHeader("X-PJAX");
        if (x_pjax != null && x_pjax.equals("true"))
            return true;
        else
        {
            /*String url = request.getRequestURI();
            url = url.replace("/index/settting/", "");*/
            request.getRequestDispatcher("/index/setting").forward(request, response);
            return false;
        }
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object o,
                           ModelAndView modelAndView) throws Exception
    {

    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object o, Exception e)
            throws Exception
    {

    }
}
